<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>Dashboard Template for Bootstrap</title>
		<!-- Bootstrap core CSS -->
		<link href="../asserts/css/bootstrap.min.css" rel="stylesheet">

		<!-- Custom styles for this template -->
		<link href="../asserts/css/dashboard.css" rel="stylesheet">
		<script src="../asserts/js/jquerySession.js"></script>

	</head>

	<body>
		<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0">
			<a class="navbar-brand col-sm-3 col-md-2 mr-0"  href="" id="schoolname" style="text-align: center">Company
				name</a>
			<input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search">
			<ul class="navbar-nav px-3">
				<li class="nav-item text-nowrap">
					<a class="nav-link" href="http://getbootstrap.com/docs/4.0/examples/dashboard/#">Sign out</a>
				</li>
			</ul>
		</nav>

		<div class="container-fluid">
			<div class="row">
				<nav class="col-md-2 d-none d-md-block bg-light sidebar">
					<div class="sidebar-sticky">
						<ul class="nav flex-column">
							<li class="nav-item">
								<a class="nav-link active" href="dashboard.html">
									<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home">
										<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
										<polyline points="9 22 9 12 15 12 15 22"></polyline>
									</svg>
									文件管理 <span class="sr-only">(current)</span>
								</a>
							</li>

						</ul>
					</div>
				</nav>

				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
					<h2>
						<a class="btn btn-sm btn-success" href="./add2.html">文件上传</a>
					</h2>
					<div class="table-responsive">
						<table class="table table-striped table-sm">
							<thead>
							<tr>
								<th>id</th>
								<th>uptime</th>
								<th>filename</th>
								<th>操作</th>
							</tr>
							</thead>
							<tbody id="tbody">
							</tbody>
						</table>
					</div>
				</main>
				<form id="deleteEmpFrom" method="post">
					<input type="hidden" name="_method" value="DELETE">
				</form>


			</div>
		</div>

		<!-- Bootstrap core JavaScript
    ================================================== -->
		<!-- Placed at the end of the document so the pages load faster -->
		<script type="text/javascript" src="../asserts/js/jquery-3.2.1.slim.min.js" ></script>
		<script type="text/javascript" src="../asserts/js/popper.min.js" ></script>
		<script type="text/javascript" src="../asserts/js/bootstrap.min.js" ></script>
		<script type="text/javascript" src="../asserts/js/jquery.min.js">	</script>

		<!-- Icons -->
		<script type="text/javascript" src="../asserts/js/feather.min.js" ></script>

	<script>
		$(function () {
            var schoolname = localStorage.getItem("schoolname");
           	$("#schoolname").html(schoolname)
            initData();
        });

        function initData() {
            var strHtml="";
            $.ajax({
				type: "GET",
                dataType: "json",
                url: "/postgraduate/files",
                success:function (res) {
				    for(var i = 0;i < res.data.length;i++){
                        strHtml += "<tr>"+
								"<td>"+res.data[i].id+"</td>"+
                            "<td>"+res.data[i].excelTime+"</td>"+
                            "<td>"+res.data[i].excelPath+"</td>"+
								"<td>"+
									"<button onclick='delFun("+res.data[i].id+")' class='btn btn-sm btn-danger deleteBtn' >删除</button>"
							+"</td>"
							+"</tr>"
					}
				    $("#tbody").append(strHtml)
                },
                error:function () {
                    alert("服务器内部错误")
                }
            });
			// $.get("/postgraduate/files",function (res) {
			// 	console.log(res);
            // })
        }

        function delFun(obj) {
			var id = obj;
			if (confirm("确认删除吗") == true){
                $.ajax({
                    type: "DELETE",
                    dataType: "json",
                    data: JSON.stringify({"id":obj}),
                    url: "/postgraduate/file/"+id,
                    success: function (res) {
                        if (res.code == 200){
                            window.location.href = "./dashboard.html"
						}else {
                        alert("删除失败")
                        }
                    },
                    error:function () {
                        alert("服务器出错")
                    }
                })
			}
			return
        }


	</script>


	</body>

</html>